// 引入外部资源
// const fs = require('fs')
// const path = require('path')
const Mock = require('mockjs')
module.exports = function (app) {
  // 登录
  app.post('/login', (req, res) => {
    const users = {
      code: '000000',
      msg: '登陆成功',
      data: {
        token: 'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOiJhZG1pbiIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdDb2RlIjoiMzUwMDAiLCJkZXB0Q29kZSI6IjM1MDAwIiwiYXVkIjoiYWRtaW4iLCJpc3MiOiJhZG1pbiIsImV4cCI6MTU5MzUzNTU5OH0.0pJAojRtT5lx6PS2gH_Q9BmBxeNlgBL37ABX22HyDlebbr66cCjVYZ0v0zbLO_9241FX9-FZpCkEqE98MQOyWw'
      }
    } // 响应时，返回 mock data的json数据
    res.json(Mock.mock(users)) // 将json传入 Mock.mock 方法中，生成的数据返回给浏览器
  })

  app.post('/getInfo', (req, res) => {
    const users =
      { msg: '操作成功', code: 200, permissions: ['*:*:*'], roles: ['admin'], user: { searchValue: null, createBy: 'admin', createTime: '2022-08-01 12:00:20', updateBy: null, updateTime: null, remark: '管理员', params: {}, userId: 1, deptId: 103, userName: 'admin', nickName: '若依', email: 'ry@163.com', phonenumber: '15888888888', sex: '1', avatar: '', password: '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', status: '0', delFlag: '0', loginIp: '112.48.57.156', loginDate: '2022-09-27T23:58:41.000+08:00', dept: { searchValue: null, createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, params: {}, deptId: 103, parentId: 101, ancestors: '0,100,101', deptName: '研发部门', orderNum: 1, leader: '若依', phone: null, email: null, status: '0', delFlag: null, parentName: null, children: [] }, roles: [{ searchValue: null, createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, params: {}, roleId: 1, roleName: '超级管理员', roleKey: 'admin', roleSort: '1', dataScope: '1', menuCheckStrictly: false, deptCheckStrictly: false, status: '0', delFlag: null, flag: false, menuIds: null, deptIds: null, permissions: null, admin: true }], roleIds: null, postIds: null, roleId: null, admin: true } }
    // 响应时，返回 mock data的json数据
    res.json(Mock.mock(users)) // 将json传入 Mock.mock 方法中，生成的数据返回给浏览器
  })

  app.post('/getRouters', (req, res) => {
    const users =
    {
      msg: '操作成功',
      code: 200,
      data: [
        // 活动收集
        {
          name: 'activeCollection',
          path: '/activeCollection',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '活动收集', icon: 'system', noCache: false, link: null },
          children: [{
            name: 'activeList',
            path: 'activeList',
            hidden: false,
            component: 'activeCollection/activeList.vue',
            meta: { title: '活动收集列表', icon: 'user', noCache: false, link: null }
          }]
        },
        // 月子中心管理
        {
          name: 'yueziCenter',
          path: '/yueziCenter',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '月子中心管理', icon: 'system', noCache: false, link: null },
          children: [{
            name: 'YueziList',
            path: 'yueziList',
            hidden: false,
            component: 'yueziCenter/YueziList.vue',
            meta: { title: '月子中心列表', icon: 'user', noCache: false, link: null }
          },
          {
            name: 'YueziAudit',
            path: 'yueziAudit',
            hidden: false,
            component: 'yueziCenter/YueziAudit.vue',
            meta: { title: '月子中心审核', icon: 'peoples', noCache: false, link: null }
          }]
        },
        // 客户管理
        {
          name: 'Monitor',
          path: '/customer',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '客户管理', icon: 'monitor', noCache: false, link: null },
          children: [{
            name: 'Online',
            path: 'clientList',
            hidden: false,
            component: 'customer/clientList.vue',
            meta: { title: '客户列表', icon: 'online', noCache: false, link: null }
          },
          {
            name: 'Job',
            path: 'job',
            hidden: false,
            component: 'customer/clientAudit.vue',
            meta: { title: '客户审核', icon: 'job', noCache: false, link: null }
          }]
        },
        // 订单管理
        {
          name: 'Tool',
          path: '/orderFrom',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '订单管理', icon: 'tool', noCache: false, link: null },
          children: [{
            name: 'Build',
            path: 'orderFromList',
            hidden: false,
            component: 'orderFrom/orderFromList.vue',
            meta: { title: '订单列表', icon: 'build', noCache: false, link: null }
          },
          {
            name: 'Gen',
            path: 'orderFromAudit',
            hidden: false,
            component: 'orderFrom/orderFromAudit.vue',
            meta: { title: '订单审核', icon: 'code', noCache: false, link: null }
          }]
        },
        // 产品柜业务
        {
          name: 'productTank',
          path: '/productTank',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '产品柜业务', icon: 'tool', noCache: false, link: null },
          children: [{
            name: 'productTankManagement',
            path: 'productTankManagement',
            hidden: false,
            component: 'productTank/ProductTankManagement.vue',
            meta: { title: '产品柜管理', icon: 'build', noCache: false, link: null }
          }]
        },
        // 礼包派发业务
        {
          name: 'gift',
          path: '/gift',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '礼包派发业务', icon: 'tool', noCache: false, link: null },
          children: [{
            name: 'Build',
            path: 'giftApple',
            hidden: false,
            component: 'gift/giftApple.vue',
            meta: { title: '礼包申请管理', icon: 'build', noCache: false, link: null }
          },
          {
            name: 'giftGet',
            path: 'giftGet',
            hidden: false,
            component: 'gift/giftGet.vue',
            meta: { title: '礼包领取管理', icon: 'code', noCache: false, link: null }
          },
          {
            name: 'giftGetVoucher',
            path: 'giftGetVoucher',
            hidden: false,
            component: 'gift/giftGetVoucher.vue',
            meta: { title: '礼包领取凭证管理', icon: 'code', noCache: false, link: null }
          }
          ]
        },

        // 财务管理
        {
          name: 'finance',
          path: '/finance',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '财务', icon: 'tool', noCache: false, link: null },
          children: [{
            name: 'Contract',
            path: 'contract',
            hidden: false,
            component: 'finance/Contract.vue',
            meta: { title: '产品柜合同管理', icon: 'build', noCache: false, link: null }
          },
          {
            name: 'Invoice',
            path: 'invoice',
            hidden: false,
            component: 'finance/Invoice.vue',
            meta: { title: '发票管理', icon: 'code', noCache: false, link: null }
          },
          {
            name: 'Borrow',
            path: 'borrow',
            hidden: false,
            component: 'finance/Borrow.vue',
            meta: { title: '借款凭证管理', icon: 'code', noCache: false, link: null }
          }
          ]
        },
        // 消息管理
        {
          name: 'newsManage',
          path: '/newsManage',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '消息管理', icon: 'tool', noCache: false, link: null },
          children: [{
            name: 'News',
            path: 'news',
            hidden: false,
            component: 'newsManage/News.vue',
            meta: { title: '消息列表', icon: 'build', noCache: false, link: null }
          },
          {
            name: 'NewsTemplate',
            path: 'newsTemplate',
            hidden: false,
            component: 'newsManage/NewsTemplate.vue',
            meta: { title: '消息模板', icon: 'code', noCache: false, link: null }
          }
          ]
        },
        {
          name: 'TrainingCourse',
          path: '/trainingCourse',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: { title: '陪训课程', icon: 'tool', noCache: false, link: null },
          children: [{
            name: 'CourseList',
            path: 'courseList',
            hidden: false,
            component: 'trainingCourse/CourseList.vue',
            meta: { title: '课程列表管理', icon: 'build', noCache: false, link: null }
          },
          {
            name: 'CourseOpen',
            path: 'courseOpen',
            hidden: false,
            component: 'trainingCourse/CourseOpen.vue',
            meta: { title: '课程陪训开放管理', icon: 'code', noCache: false, link: null }
          }
          ]
        }
      ]
    }
    // 响应时，返回 mock data的json数据
    res.json(Mock.mock(users)) // 将json传入 Mock.mock 方法中，生成的数据返回给浏览器
  })
}
